home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form DbsForm
- Caption = "Form1"
- ClientHeight = 2235
- ClientLeft = 2220
- ClientTop = 2220
- ClientWidth = 4980
- Height = 2640
- HelpContextID = 101
- Icon = DBSFORM.FRX:0000
- Left = 2160
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MDIChild = -1 'True
- ScaleHeight = 2235
- ScaleWidth = 4980
- Top = 1875
- Width = 5100
- Begin CommandButton LoadRowCmd
- Caption = "LoadRowCmd"
- Height = 375
- Left = 120
- TabIndex = 1
- Top = 1800
- Visible = 0 'False
- Width = 1455
- End
- Begin TgDemo DbsTable
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- Configurable = 0 'False
- DragIcon = DBSFORM.FRX:0302
- Editable = 0 'False
- EditBackColor = &H8000000D&
- EditForeColor = &H8000000E&
- FetchMode = 0 'By cell
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- HeadBackColor = &H80000002&
- HeadForeColor = &H80000009&
- Headings = -1 'True
- Height = 1695
- HorzColor = &H00808080&
- HorzLines = 2 '3D
- InactiveBackColor= &H00808080&
- InactiveForeColor= &H00000000&
- Layout = DBSFORM.FRX:0604
- Left = 0
- MarqueeStyle = 3 'Highlight Row
- SelectedBackColor= &H00000000&
- SelectedForeColor= &H00FFFFFF&
- SelectMode = 0 'Disabled
- TabIndex = 0
- Top = 0
- UseBookmarks = -1 'True
- VertColor = &H00808080&
- VertLines = 2 '3D
- Width = 3855
- End
- ' Local definitions for dbs form
- Dim WidthDelta As Integer
- Dim FormIndex As Integer
- Dim ourdb As Database
- Dim ourDbFile As String
- ' Map of each row
- Dim rowName() As String
- Sub DbsTable_DblClick ()
- DbsOpenCurrentTable FormIndex
- End Sub
- Sub DbsTable_DragDrop (Source As Control, X As Single, Y As Single)
- valid% = EndDragMode(MASK_NONE)
- End Sub
- Sub DbsTable_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
- valid% = DragValid(Source, MASK_NONE, State)
- End Sub
- Sub DbsTable_Fetch (Row As Long, Col As Integer, Value As String)
- ' This event is called by the grid whenever it needs
- ' data for a particular cell ... it stores no data
- ' of its own.
- rname$ = rowName(Row)
- Select Case DbsTable.ColumnName(Col)
- Case "Name"
- Value = TnameDisp(rname$)
- Case "Last Updated"
- Value = Format$(ourdb(rname$).LastUpdated)
- Case "Kind"
- Value = TnameTypeDisp(rname$)
- End Select
- End Sub
- Sub DbsTable_GotFocus ()
- ' Assure that the table menu is visible, and make
- ' a custom help message depending upon whether any
- ' tables are present.
- MDIMain.Table.Visible = True
- MDIMain.TableDelete.Enabled = (DbsTable.Rows <> 0)
- msg$ = "Tables in " + ExtractFile(ourDbFile) + " - "
- If DbsTable.Rows Then
- SetStatus msg$ + "drag or double-click to open; table menu to change"
- Else
- SetStatus msg$ + "table menu to create new tables"
- End If
- End Sub
- Sub DbsTable_LostFocus ()
- MDIMain.Table.Visible = False
- End Sub
- Sub DbsTable_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
- GridMaybeDrag DbsTable, X, Y
- End Sub
- Sub DbsTable_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
- GridTestDrag DbsTable, Button, X, Y, MASK_TABLE, Utils.DragDisk
- End Sub
- Sub DbsTable_RowChange ()
- ' element zero of rowName is always "", so if the
- ' list is empty, fiTable is ""
- DbsFormItems(FormIndex).fiTable = rowName(DbsTable.RowIndex)
- If DbsTable.RowIndex = 0 Then ' no rows
- DbsFormItems(FormIndex).fiTable = ""
- MDIMain.TableDelete.Enabled = False
- Else
- DbsFormItems(FormIndex).fiTable = rowName(DbsTable.RowIndex)
- MDIMain.TableDelete.Enabled = True
- End If
- End Sub
- Sub Form_Load ()
- ' Remember the difference between the grid width
- ' and our width for resize constraints
- WidthDelta = Me.Width - Me.ScaleWidth
- ' Capture information about our contents, passed to
- ' us from DbsOpen or DbsCreate in DBS.BAS
- FormIndex = FormLastAlloc()
- Me.Tag = FormIndex
- ourDbFile = DbsFormItems(FormIndex).fiFileName
- Set ourdb = OpenDatabase(ourDbFile)
- Set DbsFormDatabase(FormIndex) = ourdb
- DbsTable.Tag = FormIndex
- ' Fill the grid with data
- LoadRows
- End Sub
- Sub Form_Resize ()
- ' Constrain our width to the design-time grid width
- If Me.WindowState = NORMAL Then
- Me.Width = DbsTable.Width + WidthDelta
- DbsTable.Height = Me.ScaleHeight
- End If
- End Sub
- Sub Form_Unload (Cancel As Integer)
- ' Close the database when our form is closed. Other
- ' forms keep it open, so don't worry.
- ourdb.Close
- FormFree DbsFormItems(FormIndex)
- ' Kill the table menu
- MDIMain.Table.Visible = False
- End Sub
- Sub LoadRowCmd_Click ()
- ' This button is "pressed" by code in other forms
- ' when they know that a table has been added or
- ' deleted.
- LoadRows
- End Sub
- Sub LoadRows ()
- ' Loop through all the rows in the TableDefs,
- ' pruning out system tables. Fill the rowName array,
- ' and the grid Fetch event will access each table
- ' definition when it needs it.
- ReDim rowName(ourdb.TableDefs.Count)
- rowcount% = 0
- For i% = 0 To ourdb.TableDefs.Count - 1
- If (ourdb.TableDefs(i%).Attributes And DB_SYSTEMOBJECT) = 0 Then
- rowcount% = rowcount% + 1
- rowName(rowcount%) = ourdb.TableDefs(i%).Name
- End If
- Next i%
- ReDim Preserve rowName(rowcount%)
- DbsTable.Rows = rowcount%
- If rowcount% Then DbsTable.RowIndex = 1
- DbsTable.Refresh
- End Sub
-